package com.szqhyxj.youxiangju.biz.card.deposit;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.szqhyxj.youxiangju.BaseActivity;
import com.szqhyxj.youxiangju.R;
import com.szqhyxj.youxiangju.biz.card.CardModel;
import com.szqhyxj.youxiangju.sys.components.LoadImageUtils;
import com.szqhyxj.youxiangju.sys.components.NavigationBar;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 存蓄卡详情
 */
public class DepositDetailsActivity extends BaseActivity implements DepositDetailsContarct.View, NavigationBar.NavigationBarListener{

    @BindView(R.id.navigationBar)
    NavigationBar navigationBar;
    @BindView(R.id.picture)
    ImageView picture;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.card_no)
    TextView cardNo;
    @BindView(R.id.icon)
    ImageView icon;
    @BindView(R.id.issuing_bank)
    TextView issuingBank;
    @BindView(R.id.phone_code)
    TextView phoneCode;

    private static final String CARDST = "card";

    public static void start(Activity activity, CardModel.Card card){
        Intent intent = new Intent(activity, DepositDetailsActivity.class);
        intent.putExtra(CARDST, card);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_deposit_details);
        ButterKnife.bind(this);
        CardModel.Card depositDetails = getIntent().getParcelableExtra(CARDST);
        initViews();

        DepositDetailsPresenter presenter = new DepositDetailsPresenter(this);
        presenter.init(depositDetails.getCardId());
    }

    private void initViews(){
        navigationBar.setNavigationBarListener(this);
    }

    @Override
    public void showDepositDetails(CardModel.Card card){
        LoadImageUtils.loadImage(picture,card.getBankCardPic());
        LoadImageUtils.loadImage(icon,card.getCardLogo());

        name.setText(card.getUsername());
        cardNo.setText(card.getBankCardNo());
        issuingBank.setText(card.getBtName());
        phoneCode.setText(card.getCardPhone());

    }

    @Override
    public void showToast(String s) {
        Toast.makeText(this,s,Toast.LENGTH_LONG).show();
    }

    @Override
    public void navigationLeft(){
        finish();
    }

    @Override
    public void navigationRight(){
    }
}
